#include "unpack.h"

//获取当前服务器目录下的所有文件的名字
void get_filename(char* pathname,char* filename)
{
    //1.打开一个目录 
    DIR *dirp = opendir(pathname);
    if(dirp == NULL)
    {
        perror("opendir error");
        return;
    }
    //2.读取一个目录
    struct dirent * dir;
    int i = 0;
    while(dir = readdir(dirp))
    {
        strncpy(filename,dir->d_name,strlen(dir->d_name));
        i += strlen(dir->d_name);
        filename[i++] = ' ';//空格隔开
        printf("%s ",dir->d_name);//文件的名字
    }
    //3.关闭目录
    closedir(dirp);
}